Do not use generic param defaults in impls#74
Open
rmartinho wants to merge 1 commit intoyewstack:mainfrom
Open
Do not use generic param defaults in impls#74rmartinho wants to merge 1 commit intoyewstack:mainfrom
impls#74rmartinho wants to merge 1 commit intoyewstack:mainfrom
Conversation
Collaborator
|
ngl first time looking into this derive code, it is kinda weird. could just rewrite to #[proc_macro_derive(ImplicitClone)]
pub fn derive_implicit_clone(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
let mut input = syn::parse_macro_input!(item as syn::DeriveInput);
input
.generics
.type_params_mut()
.for_each(|type_param| type_param.bounds.push(syn::parse_quote! { ::implicit_clone::ImplicitClone }));
let syn::DeriveInput {
ident, generics, ..
} = input;
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
let res = quote! {
impl #impl_generics ::implicit_clone::ImplicitClone for #ident #ty_generics #where_clause {}
};
res.into()
}this way we just add bounds, and rest syn will figure out on its own |
Author
|
I'm not super familiar with writing derive macros, so I tried to change as little as necessary. I will try your implementation later and update the PR if there are no issues. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This will become an error in the future, and the defaults in
implare ignored anyway so it makes no sense to preserve them in the generatedimpl.